<!DOCTYPE html>
<html>

<head>
    <title>修改密码</title>
    <script src="static/jquery-3.6.0.min.js"></script>
</head>

<body>
    <h1>修改密码</h1>
    <form id="passwordForm">
        <label for="username">用户名：</label>
        <input type="text" id="username" name="username" required>
        <br>
        <label for="new_password">新密码：</label>
        <input type="password" id="new_password" name="new_password" required>
        <br>
        <input type="submit" value="确认修改">
    </form>

    <script>
        $(document).ready(function () {
            $('#passwordForm').submit(function (e) {
                e.preventDefault();
                var username = $('#username').val();
                var newPassword = $('#new_password').val();

                $.ajax({
                    type: 'POST',
                    url: '/change_password',
                    data: { username: username, new_password: newPassword },
                    success: function (response) {
                        alert("不要动我的密码好嘛╰(✿´⌣`✿)╯♡");  // 显示成功消息
                    },
                    error: function (error) {
                        alert('密码修改失败：' + error);  // 显示错误消息
                    }
                });
            });
        });
    </script>
</body>

</html>